package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.VisitorChartBean;
import com.topscore.uke.entities.VisitorSourceEntity;
import com.topscore.uke.mvp.contractors.GetMyVisitorsContractor;
import com.topscore.uke.mvp.model.GetMyVisitorsModel;
import com.topscore.uke.network.BaseResponse;

import java.util.List;

/**
 * Created by 71468 on 2017/10/27.
 */

public class GetVisitorsPresenter implements GetMyVisitorsContractor,GetMyVisitorsContractor.Presenter {
    private View mView;
    private Model mModel;

    public GetVisitorsPresenter(View view) {
        this.mView = view;
        mModel = new GetMyVisitorsModel(new CallBack() {
            @Override
            public void onGetChartDataSuccess(BaseResponse<List<VisitorChartBean>> response) {
                mView.onGetChartDataSuccess(response.getData());
            }

            @Override
            public void onGetVisitorSourceDataSuccess(BaseResponse<List<VisitorSourceEntity>> response) {
                mView.onGetSourceDataSuccess(response.getData());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode,errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
    }

    @Override
    public void getVisitorsData(String userID) {
        mView.onLoading("正在加载");
        mModel.getData(userID);
    }

    @Override
    public void getChartData(String userID) {
        mModel.getVisitorsChartData(userID);
    }
}
